package cc.cix.hq.file.controller;


import cc.cix.hq.common.core.entity.org.File;
import cc.cix.hq.file.service.IFileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * @author cix
 * @since 2022-06-04
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@Api(tags = "文件上传管理")
@RequestMapping("/api/file")
public class FileController {

    private final IFileService fileService;

    @ApiOperation("上传文件")
    @PostMapping
    public List<File> upload(@RequestParam List<MultipartFile> files) {
        return fileService.upload(files);
    }

    @ApiOperation("删除文件")
    @DeleteMapping("/{id}")
    public void delete(@PathVariable("id") String id) {
        fileService.delete(id);
    }

}    

